package cn.xorange.commons.data.core.mapper;

import cn.xorange.commons.data.core.entity.BaseEntity;
import cn.xorange.commons.data.dao.CrudDao;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.ExceptionUtils;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * @author yangjian
 */
@Mapper
public interface MBaseMapper<T extends BaseEntity> extends com.baomidou.mybatisplus.core.mapper.Mapper<T> {

    //@InsertProvider(type = CrudDao.class, method = "add")
    int insert(T t);
    @InsertProvider(type = CrudDao.class, method = "addBath")
    int insertBath(List<T> tList);
    @InsertProvider(type = CrudDao.class, method = "addMapBath")
    int insertBathMap(@Param("tableName") String tableName, @Param("mapList")List<Map<String,Object>> mapList);

    @UpdateProvider(type = CrudDao.class, method = "update")
    int update(T t);

    @DeleteProvider(type = CrudDao.class, method = "del")
    int del(T t);
    @DeleteProvider(type = CrudDao.class, method = "delById")
    int delById(@Param("id")Object id, Class<?> beanClass);
    @DeleteProvider(type = CrudDao.class, method = "truncate")
    void truncate(T t);
    @SelectProvider(type = CrudDao.class,method = "selectById")
    T selectById(@Param("id") Object id, Class<?> tClass);
    @SelectProvider(type = CrudDao.class,method = "selectOne")
    T select(T t);
    @SelectProvider(type = CrudDao.class,method = "selectList")
    List<T> selectList(T t);
    //@SelectProvider(type = CrudDao.class,method = "selectListAll")
    //List<T> selectListAll(Class<T> tClass);
    @SelectProvider(type = CrudDao.class,method = "selectCount")
    int count(T t);


    //mybatisPlus
    List<T> selectListPlus(@Param("ew") Wrapper<T> queryWrapper);

}
